home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / util / cdity / availmem2.lha / AvailMem2 / src / AvailMem2_bar.s next >
Text File  |  1997-07-01  |  15KB  |  630 lines

  1.  
  2.     machine 68020
  3.  
  4.     * program includes
  5.  
  6.     include    "AvailMem2_gui.i"
  7.     include    "AvailMem2.i"
  8.     include    "lvo.i"
  9.  
  10.     incdir    "include:"
  11.  
  12.     include    "exec/types.i"
  13.     include    "exec/memory.i"
  14.     include    "exec/funcdef.i"
  15.     include    "graphics/gfx.i"
  16.     include    "intuition/intuition.i"
  17.  
  18.     * program structures
  19.  
  20.  STRUCTURE    mb_Main,0        ;memory-bar structure
  21.     LONG    mb_Rport
  22.     LONG    mb_XPos
  23.     LONG    mb_YPos
  24.     LONG    mb_XWidth
  25.     LONG    mb_YHeight
  26.     LONG    mb_OldMemFree
  27.     LABEL    mb_SIZEOF
  28.  
  29.     section    code,code        ;availmem code section
  30.  
  31. _RenderBars
  32. * * * * * * * * * * * * * * * * * * * * *
  33. *                    *
  34. * Renders the memory-bars.        *
  35. *                    *
  36. * * * * * * * * * * * * * * * * * * * * *
  37.  
  38.     movem.l    d0-a6,-(sp)        ;push all registers
  39.  
  40.     lea.l    _BarList,a4        ;get ptr to bars
  41.  
  42. .RenderBars
  43.  
  44.     move.l    (a4)+,a0        ;get ptr to next bar-checkvar
  45.     move.l    a0,d0            ;put addr in d0
  46.     tst.l    d0            ;check if it IS a bar-var
  47.     beq    .NoBarsLeft        ;end looping if not
  48.  
  49.     move.l    (a0),d0            ;get checkvar state
  50.  
  51.     move.l    (a4)+,a5        ;get ptr of bar into a5
  52.     move.l    (a4)+,d3        ;get memory-attrs
  53.     move.l    (a4)+,d1        ;get bar type
  54.  
  55.     tst.l    d1            ;check if this is a CPU bar
  56.     bne    .is_CPU            ;skip if so
  57.  
  58.     tst.l    d0            ;check if i should render bar
  59.     beq    .no_refresh        ;skip if not
  60.  
  61.     move.l    (4).w,a6
  62.     move.l    d3,d1            ;get total amount of free mem
  63.     jsr    _LVOAvailMem(a6)    ;get mem free
  64.     move.l    d0,d5            ;put result in d5
  65.     cmp.l    mb_OldMemFree(a5),d5    ;check if the memory has changed
  66.     beq    .no_refresh        ;skip if not
  67.  
  68.     move.l    d5,mb_OldMemFree(a5)    ;change amount of mem free
  69.  
  70.     move.l    (4).w,a6        ;put execbase in a6
  71.     move.l    #MEMF_LARGEST,d1    ;get largest amount of free mem
  72.     or.l    d3,d1            ;add specific attributes
  73.     jsr    _LVOAvailMem(a6)    ;get largest block of memory
  74.     move.l    d0,d6            ;put largest block in d6
  75.  
  76.     move.l    (4).w,a6        ;put execbase in a6
  77.     move.l    #MEMF_TOTAL,d1
  78.     or.l    d3,d1            ;add specific attributes
  79.     jsr    _LVOAvailMem(a6)    ;get total amount of publicmem
  80.     move.l    d0,d7            ;put total amount of mem in d7
  81.  
  82.     tst.l    d7            ;check if publicmem is present
  83.     beq    .no_refresh        ;skip if not
  84.  
  85.     move.l    a5,a0            ;get ptr of publicmem bar into a0
  86.     move.l    d5,d0            ;put free mem in d0
  87.     move.l    d6,d1            ;put largest block in d1
  88.     move.l    d7,d2            ;put total amount of mem in d2
  89.     jsr    _RenderMemoryBar    ;render memory bar
  90.  
  91. .no_refresh
  92.     bra    .RenderBars        ;loop rendering
  93.  
  94. .is_CPU
  95.     tst.l    d0            ;check if i should render bar
  96.     beq    .no_refresh        ;skip if not
  97.  
  98.     move.l    d1,a0            ;put ptr to cpu usage in a0
  99.     move.l    (a0),d0            ;put cpu usage in d0
  100.     move.l    #-1,(a0)        ;reset usage
  101.     tst.l    d0            ;check if i should update
  102.     bmi    .no_refresh        ;skip if not
  103.  
  104.     move.l    d0,d1
  105.  
  106.     move.l    a5,a0            ;get ptr of cpuusage bar into a0
  107.     move.l    #101,d2            ;put maximum in d2
  108.     jsr    _RenderMemoryBar    ;render CPU bar
  109.  
  110.     bra    .RenderBars        ;loop rendering
  111.  
  112. .NoBarsLeft
  113.  
  114.     movem.l    (sp)+,d0-a6
  115.     rts
  116.  
  117.  
  118. _CalculateBars
  119. * * * * * * * * * * * * * * * * * * * * *
  120. *                    *
  121. * Calculates how the memory-bars should    *
  122. * be displayed in the window.        *
  123. *                    *
  124. * * * * * * * * * * * * * * * * * * * * *
  125.  
  126.     movem.l    d0-a6,-(sp)        ;push all registers
  127.  
  128.     clr.l    d7            ;reset number of bars
  129.  
  130.     tst.l    prg_ChipDisplayed    ;check if chip should be displayed
  131.     beq    .no_chipmem_added    ;skip if not
  132.  
  133.     add.l    #1,d7            ;increase bar-counter
  134.  
  135. .no_chipmem_added
  136.  
  137.     tst.l    prg_FastDisplayed    ;check if fast should be displayed
  138.     beq    .no_fastmem_added    ;skip if not
  139.  
  140.     add.l    #1,d7            ;increase bar-counter
  141.  
  142. .no_fastmem_added
  143.  
  144.     tst.l    prg_PublicDisplayed    ;check if public should be displayed
  145.     beq    .no_publicmem_added    ;skip if not
  146.  
  147.     add.l    #1,d7            ;increase bar-counter
  148.  
  149. .no_publicmem_added
  150.  
  151.     tst.l    prg_CPUDisplayed    ;check if CPU should be displayed
  152.     beq    .no_CPU_added        ;skip if not
  153.  
  154.     add.l    #1,d7            ;increase bar-counter
  155.  
  156. .no_CPU_added
  157.  
  158.     tst.l    d7            ;check if any bars added
  159.     beq    .Fail            :skip if not
  160.  
  161.     move.l    _GfxBase,a6        ;put gfxbase in a6
  162.     move.l    MemoryDisplayWnd,a1    ;put ptr to mem-display window in a1
  163.     move.l    wd_RPort(a1),a1        ;put win rastport in a1
  164.     move.l    #0,d0            ;set colour to zero
  165.     jsr    _LVOSetRast(a6)        ;flush window
  166.  
  167.     move.l    MemoryDisplayWnd,a1    ;put ptr to mem-display window in a1
  168.     move.w    wd_GZZHeight(a1),d0    ;get height of window
  169.     ext.l    d0            ;extend to longword
  170.  
  171.     divs.w    d7,d0            ;divide height within bars
  172.     move.l    d0,d4            ;set y-adder
  173.     sub.l    #2,d0            ;keep away from borders
  174.     move.l    d0,d3            ;set bar initial height
  175.  
  176.     cmp.l    #10,d0            ;check if bar-height<10
  177.     blo    .Fail            ;skip if true
  178.  
  179.     move.w    wd_GZZWidth(a1),d0    ;put window width in d0
  180.     sub.w    #4,d0            ;substract minimum plain area
  181.  
  182.     ext.l    d0            ;extend to longword
  183.  
  184.     move.l    d0,d2            ;put bar-area in d2
  185.  
  186.     move.l    wd_RPort(a1),a1        ;get window rast-port into a1
  187.     move.l    #2,d0            ;set bar initial x-pos
  188.     move.l    #1,d1            ;set bar initial y-pos
  189.  
  190.     tst.l    prg_ChipDisplayed    ;check if chip-bar should be displayed
  191.     beq    .no_chipbar        ;skip if not
  192.  
  193.     lea.l    prg_ChipmemBar,a0    ;get ptr to chipbar into a0
  194.     jsr    _InitializeBar        ;initalize fast-bar
  195.  
  196.     add.l    d4,d1            ;increase y
  197.  
  198. .no_chipbar
  199.  
  200.     tst.l    prg_FastDisplayed    ;check if fast-bar should be displayed
  201.     beq    .no_fastbar        ;skip if not
  202.  
  203.     lea.l    prg_FastmemBar,a0    ;get ptr to fastbar into a0
  204.     jsr    _InitializeBar        ;initalize fast-bar
  205.  
  206.     add.l    d4,d1            ;increase y
  207.  
  208. .no_fastbar
  209.  
  210.     tst.l    prg_PublicDisplayed    ;check if public-bar should be displayed
  211.     beq    .no_publicbar        ;skip if not
  212.  
  213.     lea.l    prg_PublicmemBar,a0    ;get ptr to publicbar into a0
  214.     jsr    _InitializeBar        ;initalize public-bar
  215.  
  216.     add.l    d4,d1            ;increase y
  217.  
  218. .no_publicbar
  219.  
  220.     tst.l    prg_CPUDisplayed    ;check if cpu-bar should be displayed
  221.     beq    .no_cpubar        ;skip if not
  222.  
  223.     lea.l    prg_CPUUsageBar,a0    ;get ptr to cpubar into a0
  224.     jsr    _InitializeBar        ;initalize cpu-bar
  225.  
  226.     add.l    d4,d1            ;increase y
  227.  
  228. .no_cpubar
  229.  
  230. .AllBarsFixed
  231.     movem.l    (sp)+,d0-a6        ;pop all registers
  232.     st.l    prg_RenderBarsOk
  233.     rts                ;return
  234.  
  235. .Fail
  236.     movem.l    (sp)+,d0-a6        ;pop all registers
  237.     clr.l    prg_RenderBarsOk
  238.     rts                ;return
  239.  
  240. _InitializeBar
  241. * * * * * * * * * * * * * * * * * * * * *
  242. *                    *
  243. * Initialize a memory-display bar.    *
  244. *                    *
  245. * IN:    a0 - ptr to bar structure.    *
  246. *    a1 - ptr to window rastport.    *
  247. *    d0 - x-position.        *
  248. *    d1 - y-position.        *
  249. *    d2 - x width.            *
  250. *    d3 - y height.            *
  251. *                    *
  252. * * * * * * * * * * * * * * * * * * * * *
  253.  
  254.     movem.l    d0-a6,-(sp)        ;push all registers
  255.  
  256.     move.l    a0,a5            ;put ptr to bar in a5
  257.     move.l    a1,mb_Rport(a5)        ;store bar rastport
  258.     move.l    d0,mb_XPos(a5)        ;store bar x-pos
  259.     move.l    d1,mb_YPos(a5)        ;store bar y-pos
  260.     move.l    d2,mb_XWidth(a5)    ;store bar x-width
  261.     move.l    d3,mb_YHeight(a5)    ;store bar y-height
  262.     move.l    #-1,mb_OldMemFree(a5)    ;reset memory-hold
  263.  
  264.     lea.l    .BlackBorderVec,a0    
  265.     move.w    d3,2(a0)        
  266.     move.w    d2,8(a0)        
  267.     lea.l    .WhiteBorderVec,a0    
  268.     move.w    d2,(a0)            
  269.     move.w    d2,4(a0)        
  270.     move.w    d3,6(a0)        
  271.     move.w    d3,10(a0)        
  272.  
  273.     move.l    _IntuitionBase,a6    
  274.     move.l    mb_Rport(a5),a0        
  275.     lea.l    .MemBorder,a1        
  276.     jsr    _LVODrawBorder(a6)    
  277.  
  278.     move.l    _GfxBase,a6        
  279.     move.l    mb_Rport(a5),a1        
  280.     move.l    #0,d0            
  281.     jsr    _LVOSetAPen(a6)        
  282.  
  283.     move.l    mb_Rport(a5),a1        
  284.     move.l    mb_XPos(a5),d0        
  285.     move.l    mb_YPos(a5),d1        
  286.     move.l    mb_XWidth(a5),d2    
  287.     move.l    mb_YHeight(a5),d3    
  288.     add.l    d0,d2            
  289.     add.l    d1,d3            
  290.     subq.l    #1,d2            
  291.     subq.l    #1,d3            
  292.     addq.l    #1,d0            
  293.     addq.l    #1,d1            
  294.     jsr    _LVORectFill(a6)    
  295.  
  296.     movem.l    (sp)+,d0-a6        ;pop all registers
  297.     rts                ;return
  298.  
  299. .MemBorder    dc.w    0,0
  300.         dc.b    1,0,RP_JAM1
  301.         dc.b    3
  302.         dc.l    .BlackBorderVec
  303.         dc.l    .WhiteBorder
  304. .WhiteBorder    dc.w    0,0
  305.         dc.b    2,0,RP_JAM1
  306.         dc.b    3
  307.         dc.l    .WhiteBorderVec
  308.         dc.l    0
  309. .BlackBorderVec    ds.l    3
  310. .WhiteBorderVec    ds.l    3
  311.  
  312. _AddFlushGadget
  313. * * * * * * * * * * * * * * * * * * * * *
  314. *                    *
  315. * Adds flush-gadgets to the memdisplay    *
  316. * window.                *
  317. *                    *
  318. * * * * * * * * * * * * * * * * * * * * *
  319.  
  320.     movem.l    d0-a6,-(sp)        ;pop all registers
  321.  
  322.     move.l    _IntuitionBase,a6    ;put intuitionbase in a6
  323.     lea.l    _FlushGadgetList,a4    ;get ptr to flushgadget-list into a4
  324.  
  325. .AddFlushGadgets
  326.     move.l    (a4)+,a0        ;get ptr to next bar-checkvar
  327.     move.l    a0,d0            ;put addr in d0
  328.     tst.l    d0            ;check if it IS a bar-var
  329.     beq    .NoGadgetsLeft        ;end looping if not
  330.  
  331.     move.l    (a0),d0            ;get checkvar state
  332.  
  333.     move.l    (a4)+,a1        ;get ptr to flush-gadget into a1
  334.     move.l    (a4)+,a2        ;get ptr to mem-bar into a2
  335.  
  336.     tst.l    d0            ;check if bar exist
  337.     beq    .no_gadget        ;skip if not
  338.  
  339.     move.w    #GFLG_GADGHBOX,gg_Flags(a1)
  340.     move.w    #GACT_RELVERIFY,gg_Activation(a1)
  341.     move.w    #GTYP_BOOLGADGET,gg_GadgetType(a1)
  342.  
  343.     move.l    MemoryDisplayWnd,a0    ;put ptr to mem-display window into a0
  344.     move.l    #0,d0            ;reset d0
  345.  
  346.     move.w    mb_XPos+2(a2),d0
  347.     add.w    #1,d0
  348.     move.w    d0,gg_LeftEdge(a1)
  349.     move.w    mb_YPos+2(a2),d0
  350.     add.w    #1,d0
  351.     move.w    d0,gg_TopEdge(a1)
  352.  
  353.     move.w    mb_XWidth+2(a2),d0
  354.     sub.w    #1,d0
  355.     move.w    d0,gg_Width(a1)
  356.  
  357.     move.w    mb_YHeight+2(a2),d0
  358.     sub.w    #1,d0
  359.     move.w    d0,gg_Height(a1)
  360.  
  361.     jsr    _LVOAddGadget(a6)    ;add one flush-gadget
  362.  
  363. .no_gadget
  364.     bra    .AddFlushGadgets    ;loop
  365.  
  366. .NoGadgetsLeft
  367.  
  368.     movem.l    (sp)+,d0-a6        ;push all registers
  369.     rts                ;return
  370.  
  371. _RenderMemoryBar
  372. * * * * * * * * * * * * * * * * * * * * *
  373. *                    *
  374. * Renders a memory-bar.            *
  375. *                    *
  376. * IN:    a0 - ptr to memory-bar.        *
  377. *    d0 - memory available.        *
  378. *    d1 - largest memory-block.    *
  379. *    d2 - Total memory.        *
  380. *                    *
  381. * * * * * * * * * * * * * * * * * * * * *
  382.  
  383.     movem.l    d0-a6,-(sp)        ;push all registers
  384.  
  385.     move.l    a0,a5            ;put memory-bar in a5
  386.     move.l    d0,d5            ;put mem-avail in d5
  387.     move.l    d1,d6            ;put mem-largest in d6
  388.     move.l    d2,d7            ;put mem-full in d7
  389.  
  390.     muls.l    #100,d5            ;multiplicate mem-avail with 100
  391.     divs.l    d7,d5            ;divide mem-avail with mem-full
  392.     move.w    d5,.PercentValue    ;store percentage free
  393.     move.l    mb_XWidth(a5),d3    ;put mem-bar xwidth into d3
  394.     muls.l    d3,d5            ;multiplicate mem-prc with width
  395.     divs.l    #100,d5            ;divide with 100
  396.  
  397.     muls.l    #100,d6            ;multiplicate mem-largest with 100
  398.     divs.l    d7,d6            ;divide mem-largest with mem-full
  399.     move.l    mb_XWidth(a5),d3    ;put mem-bar xwidth into d3
  400.     muls.l    d3,d6            ;multiplicate mem-prc with width
  401.     divs.l    #100,d6            ;divide with 100
  402.  
  403.     move.l    _GfxBase,a6        ;put gfxbase in a6
  404.     move.l    mb_Rport(a5),a1        ;put bar rastport into a1
  405.     move.l    prg_RemaMemBlkColour,d0    ;put remaining mem bar colour in d0
  406.     jsr    _LVOSetAPen(a6)        ;set rastport draw colour
  407.  
  408.     move.l    d5,d7            ;put mem-free in d7
  409.     sub.l    d6,d7            ;subtract mem-largest
  410.     tst.l    d7            ;check if largest is as large as free
  411.     bmi    .no_largestblock    ;skip if so
  412.  
  413.     move.l    mb_Rport(a5),a1        ;put bar rastport into a1
  414.     move.l    mb_XPos(a5),d0        ;put bar xpos into d0
  415.     add.l    d6,d0            ;add 
  416.     move.l    mb_YPos(a5),d1
  417.     move.l    d7,d2
  418.     move.l    mb_YHeight(a5),d3
  419.     add.l    d0,d2
  420.     add.l    d1,d3
  421.     addq.l    #1,d2
  422.     subq.l    #1,d3
  423.     addq.l    #1,d0
  424.     addq.l    #1,d1
  425.     jsr    _LVORectFill(a6)
  426.  
  427. .no_largestblock
  428.  
  429.     move.l    _GfxBase,a6
  430.     move.l    mb_Rport(a5),a1
  431.     move.l    prg_LargMemBlkColour,d0
  432.     jsr    _LVOSetAPen(a6)
  433.  
  434.     move.l    mb_Rport(a5),a1
  435.     move.l    mb_XPos(a5),d0
  436.     move.l    mb_YPos(a5),d1
  437.     move.l    d6,d2
  438.     move.l    mb_YHeight(a5),d3
  439.     add.l    d0,d2
  440.     add.l    d1,d3
  441.     subq.l    #1,d3
  442.     addq.l    #1,d0
  443.     addq.l    #1,d1
  444.     jsr    _LVORectFill(a6)
  445.  
  446.     move.l    _GfxBase,a6
  447.     move.l    mb_Rport(a5),a1
  448.     move.l    #0,d0
  449.     jsr    _LVOSetAPen(a6)
  450.  
  451.     move.l    mb_Rport(a5),a1        ;put mem-display rastport in a1
  452.     move.l    mb_XPos(a5),d0        ;put bar x-pos in d0
  453.     add.l    d5,d0            ;add total amount of free mem to d0
  454.     move.l    mb_YPos(a5),d1        ;put ypos into d1
  455.     move.l    mb_XPos(a5),d2        
  456.     add.l    mb_XWidth(a5),d2
  457.     move.l    mb_YHeight(a5),d3
  458.     add.l    d1,d3
  459.     subq.l    #1,d2
  460.     subq.l    #1,d3
  461.     addq.l    #1,d0
  462.     addq.l    #1,d1
  463.     jsr    _LVORectFill(a6)    ;clear allocated area
  464.  
  465.     tst.l    prg_RenderLines
  466.     beq    .no_lines
  467.  
  468.     move.l    _GfxBase,a6
  469.     move.l    mb_Rport(a5),a1
  470.  
  471.     move.l    _GfxBase,a6
  472.     move.l    mb_Rport(a5),a1
  473.     move.l    #1,d0
  474.     jsr    _LVOSetAPen(a6)
  475.  
  476.     move.l    mb_Rport(a5),a1
  477.     move.l    d6,d0
  478.     add.l    mb_XPos(a5),d0
  479.     move.l    mb_YPos(a5),d1
  480.     addq.l    #1,d1
  481.     jsr    _LVOMove(a6)
  482.  
  483.     move.l    mb_Rport(a5),a1
  484.     move.l    d6,d0
  485.     add.l    mb_XPos(a5),d0
  486.     move.l    mb_YPos(a5),d1
  487.     add.l    mb_YHeight(a5),d1
  488.     subq.l    #1,d1
  489.     jsr    _LVODraw(a6)
  490.  
  491.     move.l    mb_Rport(a5),a1
  492.     move.l    d5,d0
  493.     add.l    mb_XPos(a5),d0
  494.     move.l    mb_YPos(a5),d1
  495.     addq.l    #1,d1
  496.     jsr    _LVOMove(a6)
  497.  
  498.     move.l    mb_Rport(a5),a1
  499.     move.l    d5,d0
  500.     add.l    mb_XPos(a5),d0
  501.     move.l    mb_YPos(a5),d1
  502.     add.l    mb_YHeight(a5),d1
  503.     subq.l    #1,d1
  504.     jsr    _LVODraw(a6)
  505. .no_lines
  506.  
  507.     tst.l    prg_RenderPercentage    ;check if i should render percents
  508.     beq    .no_Percentage        ;skip if not
  509.  
  510.     clr.l    .CharCount        ;reset character count
  511.  
  512.     move.l    (4).w,a6        ;put execbase in a6
  513.     lea.l    .PercentMask,a0        ;get ptr to stringmask into a0
  514.     lea.l    .PercentValue,a1    ;get ptr to percentage into a1
  515.     lea.l    .parse_PercentString,a2    ;put ptr to output routine into a2
  516.     lea.l    .PercentString,a3    ;put pointer to output string into a3
  517.     jsr    _LVORawDoFmt(a6)    ;generate percentage string
  518.  
  519.     move.l    _GfxBase,a6        ;put gfxbase in a6
  520.     move.l    mb_Rport(A5),a1        ;put bar rastport in a1
  521.     lea.l    .PercentString,a0    ;get pointer to percent string into a0
  522.     move.l    .CharCount,d0        ;put number of chars into d0
  523.     sub.l    #1,d0            ;get correct size
  524.     jsr    _LVOTextLength(a6)    ;evaluate text-string width
  525.     lsr.l    #1,d0            ;halven width
  526.     move.l    d0,d6            ;store text-centered width
  527.  
  528.     move.l    MemoryDisplayWnd,a4    ;put ptr to mem-display window in a4
  529.     move.l    wd_IFont(a4),a3        ;put pointer to window font in a3
  530.  
  531.     move.l    mb_YHeight(a5),d2    ;get memory-bar y-height into d2
  532.     sub.l    #2,d2            ;make sure there is space left on bar
  533.     cmp.w    tf_YSize(a3),d2        ;check if font height is larger than the bar
  534.     blo    .no_Percentage        ;skip if font is larger
  535.  
  536.     move.l    _GfxBase,a6        ;put gfxbase in a6
  537.     move.l    mb_Rport(a5),a1        ;put mem-display rastport in a1
  538.  
  539.     * WARNING! I DO WORD ACCESS WITH THE BAR
  540.     * POSITION AND SIZE COUNTERS HERE! I GET
  541.     * PAST A FEW NASTY BUGS THAT WAY!
  542.  
  543.     * center x-axis
  544.  
  545.     move.w    mb_XPos+2(a5),d0    ;put bar x-pos in d0
  546.  
  547.     sub.w    d6,d0            ;sub text-centered width
  548.  
  549.     move.w    mb_XWidth+2(a5),d2    ;get bar width in d2
  550.     lsr.w    #1,d2            ;divide by 2
  551.     add.w    d2,d0            ;add half bar width to text-pos
  552.  
  553.     * centre y-axis
  554.     move.w    mb_YPos+2(a5),d1    ;put bar y-pos in d1
  555.  
  556.     add.w    tf_Baseline(a3),d1    ;add window-font baseline
  557.  
  558.     move.w    mb_YHeight+2(a5),d2
  559.     lsr.w    #1,d2
  560.     add.w    d2,d1
  561.  
  562.     move.w    tf_YSize(a3),d2
  563.     lsr.w    #1,d2
  564.     sub.w    d2,d1
  565.     addq.w    #1,d1
  566.  
  567.     jsr    _LVOMove(a6)        ;set gr-coordinates
  568.  
  569.     move.l    _GfxBase,a6        ;put gfxbase in a6
  570.     move.l    mb_Rport(a5),a1        ;put rastport in a1
  571.     move.l    #RP_JAM1,d0        ;use JAM1 draw mode
  572.     jsr    _LVOSetDrMd(a6)        ;set drawmode
  573.  
  574.     move.l    mb_Rport(a5),a1
  575.     move.l    #1,d0
  576.     jsr    _LVOSetAPen(a6)        ;set
  577.  
  578.     move.l    mb_Rport(a5),a1        ;put mem-display rastport in a1
  579.     lea.l    .PercentString,a0    ;put string in a0
  580.     move.l    .CharCount,d0        ;put number of chars to be output
  581.     subq.l    #1,d0            ;get correct amount of chars
  582.     jsr    _LVOText(a6)        ;write percentage
  583.  
  584. .no_Percentage
  585.  
  586.     movem.l    (sp)+,d0-a6        ;pop all registers
  587.     rts                ;return
  588.  
  589. .parse_PercentString
  590.     move.b    d0,(a3)+        ;output next char
  591.     add.l    #1,.CharCount        ;increase char-counter
  592.     rts
  593.  
  594. .PercentMask    dc.b    "%d%%",0
  595. .PercentValue    ds.l    1
  596. .CharCount    ds.l    1
  597. .PercentString    ds.b    6
  598.  
  599. _BarList
  600.     dc.l    prg_ChipDisplayed,prg_ChipmemBar,MEMF_CHIP,FALSE
  601.     dc.l    prg_FastDisplayed,prg_FastmemBar,MEMF_FAST,FALSE
  602.     dc.l    prg_PublicDisplayed,prg_PublicmemBar,0,FALSE
  603.     dc.l    prg_CPUDisplayed,prg_CPUUsageBar,0,prg_CPUUsage
  604.     dc.l    0
  605.  
  606. _FlushGadgetList
  607.     dc.l    prg_ChipDisplayed,ChipFlushGadget,prg_ChipmemBar
  608.     dc.l    prg_FastDisplayed,FastFlushGadget,prg_FastmemBar
  609.     dc.l    prg_PublicDisplayed,PublicFlushGadget,prg_PublicmemBar
  610.     dc.l    0
  611.  
  612.  
  613.     section    bss,bss            ;availmem bss section
  614.  
  615. * program variables
  616.  
  617. prg_RenderBarsOk    ds.l    1    ;program renderbars bool
  618.  
  619. * program flush gadgets
  620.  
  621. ChipFlushGadget        ds.b    gg_SIZEOF
  622. FastFlushGadget        ds.b    gg_SIZEOF
  623. PublicFlushGadget    ds.b    gg_SIZEOF
  624.  
  625. * program memorybar structures
  626.  
  627. prg_ChipmemBar        ds.b    mb_SIZEOF
  628. prg_FastmemBar        ds.b    mb_SIZEOF
  629. prg_PublicmemBar    ds.b    mb_SIZEOF
  630. prg_CPUUsageBar        ds.b    mb_SIZEOF